import * as types from '../../mutation-types/sales-category/index';

const state = {
    salesCategoryList : [],
    currentPage :1,
    totalCount : 1
};

const mutations = {
	[types.SALES_CATEGORYLIST] (state , {salesCategoryList}){
		state.salesCategoryList = salesCategoryList;
	},
	[types.SALES_CATEGORYLIST_DEL] (state , {index}){
		const list = state.salesCategoryList.concat([]);
		const arr = [];
		list.forEach((n,i)=>{
			if(index.indexOf(i)<=-1){
				arr.push(n);
			}
		});
		state.salesCategoryList = arr;
	},
	[types.SALES_CATEGORYLIST_CURRENTPAGE] (state , {currentPage}){
		state.currentPage = currentPage;
	},
	[types.SALES_CATEGORYLIST_TOTALCOUNT] (state , {totalCount}){
		state.totalCount = totalCount;
	},
	[types.SALES_CATEGORYLIST_ADD] (state , preload){
		//state.salesCategoryList.push(preload);
	},

	[types.SALES_CATEGORYLIST_EDIT] (state , preload){
		//state.totalCount = totalCount;
	},

};

export default {
	state ,
	mutations
};
